$(function(){
    "use strict";

    // 当点击直接投入的时候
    $('.directInto_box>p').click(function(){
        $(this).siblings('ul.directInto_list').toggleClass('active')
    })
    //当点击核算确定的时候
    $('#check').on('click','.cancel_btn',function(){
        $('#check').removeClass('active')
    })
    // 点击出现搜索框
    $('.hidden_box_showBox').click(function(){
        $(this).siblings('.hidden_box_hiddenBox').toggleClass('active')
        //进入时，直接请求搜索框中需要的数据
        if($(this).children('i').hasClass('icon-jiantou')){
            $(this).children('i').removeClass('icon-jiantou').addClass('icon-jiantou-top')
            let that = this
            $.ajax({//部门
                url:'http://jk.com/Admin/Org/showDep',
                type:'get',
                success:function(data){
                    let showDepHTML = ''
                    for(var sdi=0;sdi<data.length;sdi++){
                        showDepHTML += `
                    <option value="${data[sdi].id}">${data[sdi].dep_name}</option>
                `
                    }
                    $(that).siblings('.hidden_box_hiddenBox').find('[data-query="dep"]').html(showDepHTML)
                }
            })
            $.ajax({//人
                url:'http://jk.com/Admin/Pay/getStaffName',
                type:'get',
                success:function(data){
                    let peoplehtmls = ''
                    for(var pi=0;pi<data.length;pi++){
                        peoplehtmls += `
                            <option value="${data[pi].id}" data-dep="${data[pi].dep_name}">${data[pi].staff_name}</option>
                        `
                    }
                    $(that).siblings('.hidden_box_hiddenBox').find('[data-query="name"]').html(peoplehtmls)
                }
            })
            $.ajax({//设备
                url:'http://jk.com/Admin/ProDevice/getDevName',
                type:'get',
                // xhrFields: { withCredentials: true }, crossDomain: true,
                success:function(data){
                    let eqhtml = ''
                    for(var eqi=0;eqi<data.length;eqi++){
                        eqhtml += `
                            <option value="${data[eqi].id}" data-eq="${data[eqi].dev_sn}">${data[eqi].dev_name}</option>
                        `
                    }
                    $(that).siblings('.hidden_box_hiddenBox').find('[data-query="eq"]').html(eqhtml)
                }
            })
        }else{
            $(this).children('i').removeClass('icon-jiantou-top').addClass('icon-jiantou')
        }
    })
    // 当确定搜索时
    $('.hiddenBox_list_btn').on('click','button',function(){
        $('.hidden_box_hiddenBox').removeClass('active')
        $('.hidden_box_showBox').children('i').removeClass('icon-jiantou-top').addClass('icon-jiantou')
        if($(this).html() == '确定'){
            $('#dateVal').html(window.query_year_people||'全部')

            let time = $(this).closest('.hidden_box_hiddenBox').find('[data-query="time"]').val()
            let eq = $(this).closest('.hidden_box_hiddenBox').find('[data-query="eq"]').val()
            let name = $(this).closest('.hidden_box_hiddenBox').find('[data-query="name"]').val()
            let dep = $(this).closest('.hidden_box_hiddenBox').find('[data-query="dep"]').val()
            window.location.href = `http://jk.com/Admin/Pay/index?dep_id=${dep}&dev_name=${eq}$staff_name=${name}&time=${time}`
        }else{
            window.query_year_people = null
        }
    })
    //当点击查看记录时
    $('#table_table').on('click','.look_record_btn',function(e){
        e.preventDefault()
        $(this).siblings('.tip_hiddenBox').addClass('active')
    })
    // 当点击工时记录中确认按钮时
    $('#table_table').on('click','.work_record_box>.btn',function(e){
        e.preventDefault()
        $(this).parent().removeClass('active')
    })
    //全选的功能
    $('#checkAll').on('click',function(){
        var checkboxs =$('input[type=checkbox]:not("#checkAll")');
        for(var i=0;i<checkboxs.length;i++){
            var checkbox=checkboxs[i];
            checkbox.checked=this.checked;
        }
    })
    $('#table_table').on('click','input[type=checkbox]:not("#checkAll")',function(){
        "use strict";
        var isCheckedAll = true;
        var checkboxs =$('input[type=checkbox]:not("#checkAll")');
        for (var i = 0; i < checkboxs.length; i++) {
            if (!checkboxs[i].checked) {
                isCheckedAll = false;
                break;
            }
        }
        $('#checkAll')[0].checked = isCheckedAll;
    })

    /*当点击添加按钮时*/
    $('.operation_btn').on('click','a',function(e){
        e.preventDefault()
        if( $(this).html() == '添加' ){
            var add_people = $(this).attr('href')
            $(`[lll=${add_people}]`).addClass('active')
            let peoplehtmls = '';
            let eqhtml = ''
            $.ajax({
                url:'http://jk.com/Admin/Pay/getStaffName',
                type:'get',
                success:function(data){
                    for(var i=0;i<data.length;i++){
                        peoplehtmls += `
                            <option value="${data[i].id}" data-dep="${data[i].dep_name}">${data[i].staff_name}</option>
                        `
                    }
                    $(`[lll=${add_people}]`).find('[add_name="add_name"]').html(peoplehtmls)
                }
            })
            $.ajax({
                url:'http://jk.com/Admin/ProDevice/getDevName',
                type:'get',
                success:function(data){
                    for(var i=0;i<data.length;i++){
                        eqhtml += `
                            <option value="${data[i].id}" data-eq="${data[i].dev_sn}">${data[i].dev_name}</option>
                        `
                    }
                    $(`[lll=${add_people}]`).find('[add_name="add_equipmentName"]').html(eqhtml)
                }
            })
        }
        if( $(this).html() == '核算' ){
            var add_people = $(this).attr('href')
            var checkboxs =$('#table_table input[type=checkbox]:not("#checkAll")');
            var len = 0;
            let hs_arr = [];
            for (var i = 0; i < checkboxs.length; i++) {
                if (checkboxs[i].checked) {
                    continue
                }else{
                    len++
                }
            }
            if(len == checkboxs.length){
                $('#yz_modal').html('您还没有选择记录！')
                $('#yz_modal').addClass('active')
                tipShow()
                return
            }else{
                for (let hsi = 0; hsi < checkboxs.length; hsi++) {
                    if (checkboxs[hsi].checked) {
                        hs_arr.push( $(checkboxs[hsi]).closest('tr[data-index]').attr('data-index') )
                    }else{
                        continue;
                    }
                }
                $.ajax({
                    url:'http://jk.com/Admin/ProDevice/calCulDevice',
                    type:'get',
                    data:{
                        id:hs_arr
                    },
                    success:function(data){
                        if(data.code==1){
                            console.log(data)
                        }else{
                            $(add_people).addClass('active')
                        }
                    }
                })
            }


        }
        if( $(this).html() == '批量删除' ){
            var checkboxs =$('input[type=checkbox]:not("#checkAll")');
            var len = 0;
            for (var i = 0; i < checkboxs.length; i++) {
                if (checkboxs[i].checked) {
                    continue
                }else{
                    len++
                }
            }
            if(len == checkboxs.length){
                $('#yz_modal').html('您还没有选择人员！')
                $('#yz_modal').addClass('active')
                tipShow()
                return
            }else{
                let _delete = $(this).attr('href');
                $(_delete).addClass('active')
            }

        }
        if( $(this).html() == '批量导入' ){
            let showbox_id = $(this).attr('href');
            $(showbox_id).addClass('active')
        }
    })
    //人员选择之后自动显示人员所在部门
    $(`[lll='add_people']`).find('[add_name="add_name"]').change(function(){
        let dep = $(this).children('option:selected').attr('data-dep')
        $(`[lll='add_people']`).find('[add_name="add_department"]').val(dep)
    })
    //设备选择之后自动显示设备编号
    $(`[lll='add_people']`).find('[add_name="add_equipmentName"]').change(function(){
        let eq = $(this).children('option:selected').attr('data-eq')
        $(`[lll='add_people']`).find('[add_name="add_equipmentNum"]').val(eq)
    })

    // 批量删除
    $('.delete_tip_btn_box').on('click','button',function(){
        "use strict";
        let delete_arr = [];
        if($(this).html() == '确认'){
            let checkboxs =$('#table_table input[type=checkbox]:not("#checkAll")');
            for (let i = 0; i < checkboxs.length; i++) {
                if (checkboxs[i].checked) {
                    delete_arr.push( $(checkboxs[i]).closest('tr[data-index]').attr('data-index') )
                }else{
                    continue;
                }
            }
            $.ajax({
                url:'http://jk.com/Admin/ProStaff/multiDelStaff',
                type:'post',
                data:{
                    pro_dev_id: delete_arr
                },
                success:function(data){
                    if(data.code==1){
                        for(let r = 0; r < delete_arr.length; r++){
                            $('#table_table').children('tbody').children(`[data-index=${delete_arr[r]}]`).remove();
                        }
                        $('#delete').removeClass('active')
                    }else{
                        $('#yz_modal').html(data.msg)
                        $('#yz_modal').addClass('active')
                        tipShow()
                        return
                    }
                    checkBox()
                }
            })

        }else{
            $('#delete').removeClass('active')

        }
    })

    // 当点击编辑按钮时
    $('#table_table').on('click','.edit_table',function(e){
        e.preventDefault()
        var edit_box = $(this).attr('href')
        if($(this).html()=='编辑') {
            let edit_id = $(this).closest('tr').attr('data-index')
            let edit_peopleHTML = ''
            let edit_eqHTML = ''
            $.ajax({
                url: 'http://jk.com/Admin/Pay/getStaffName',
                type: 'get',
                success: function (data) {
                    for (var epi = 0; epi < data.length; epi++) {
                        edit_peopleHTML += `
                            <option value="${data[epi].id}" data-dep="${data[epi].dep_name}">${data[epi].staff_name}</option>
                        `
                    }
                    $(`[lll=${edit_box}]`).find('[add_name="edit_name"]').html(edit_peopleHTML)
                }
            })
            $.ajax({
                url: 'http://jk.com/Admin/ProDevice/getDevName',
                type: 'get',
                success: function (data) {
                    console.log(data)
                    for (var eei = 0; eei < data.length; eei++) {
                        edit_eqHTML += `
                            <option value="${data[eei].id}" data-eq="${data[eei].dev_sn}">${data[eei].dev_name}</option>
                        `
                    }
                    $(`[lll=${edit_box}]`).find('[add_name="edit_equipmentName"]').html(edit_eqHTML)
                }
            })
            $.ajax({
                url:'http://jk.com/Admin/ProDevice/editDevice',
                type:'get',
                data:{id:edit_id},
                success:function(data){
                    if(data.code==1){
                        let datas = data.data
                        $(`[lll=${edit_box}]`).find('[add_name=start_time_edit]').val(datas.start_time)
                        $(`[lll=${edit_box}]`).find('[add_name=end_time_edit]').val(datas.end_time)
                        $(`[lll=${edit_box}]`).find('[add_name=edit_equipmentName]').val(datas.dev_id)
                        $(`[lll=${edit_box}]`).find('[add_name=edit_equipmentNum]').val(datas.dev_sn)
                        $(`[lll=${edit_box}]`).find('[add_name=edit_name]').val(datas.staff_id)
                        $(`[lll=${edit_box}]`).find('[add_name=edit_department]').val(datas.dep_name)
                        $(`[lll=${edit_box}]`).find('[add_name=edit_workTime]').val(datas.work_hours)
                        $(`[lll=${edit_box}]`).find('[add_name=edit_equipmentUseRecord]').val(datas.work_record)

                        window.sessionStorage['edit_id']=edit_id
                        $(`[lll=${edit_box}]`).addClass('active')
                    }else{

                    }
                }
            })
        }
    })
    //人员选择之后自动显示人员所在部门
    $(`[lll='edit_people']`).find('[add_name="edit_name"]').change(function(){
        let dep = $(this).children('option:selected').attr('data-dep')
        $(`[lll='edit_people']`).find('[add_name="edit_department"]').val(dep)
    })
    //设备选择之后自动显示设备编号
    $(`[lll='edit_people']`).find('[add_name="edit_equipmentName"]').change(function(){
        let eq = $(this).children('option:selected').attr('data-eq')
        $(`[lll='edit_people']`).find('[add_name="edit_equipmentNum"]').val(eq)
    })

// 保存按钮点击时
    $('#save_btn').click(function(){
        let start_time_edit = $(this).closest('[lll]').find('[add_name=start_time_edit]').val()
        let end_time_edit = $(this).closest('[lll]').find('[add_name=end_time_edit]').val()

        let edit_equipmentName_id = $(this).closest('[lll]').find('[add_name=edit_equipmentName]').val()
        let edit_equipmentName = $(this).closest('[lll]').find('[add_name=edit_equipmentName] option:selected').text()
        let edit_equipmentNum = $(this).closest('[lll]').find('[add_name=edit_equipmentNum]').val()
        let edit_name_id = $(this).closest('[lll]').find('[add_name=edit_name]').val()
        let edit_name = $(this).closest('[lll]').find('[add_name=edit_name] option:selected').text()
        let edit_department = $(this).closest('[lll]').find('[add_name=edit_department]').val()
        let edit_workTime = $(this).closest('[lll]').find('[add_name=edit_workTime]').val()
        let edit_equipmentUseRecord = $(this).closest('[lll]').find('[add_name=edit_equipmentUseRecord]').val()/**/

        var start_timeList = start_time_edit.split('-')
        var end_timeList = end_time_edit.split('-')
        var start_time_edit_month = start_timeList[1]
        var end_time_edit_month = end_timeList[1]
        var start_time_edit_date = start_timeList[2]
        var end_time_edit_date = end_timeList[2]

        let edit_id = window.sessionStorage['edit_id']
        let that = this
        if(start_time_edit_month != end_time_edit_month){
            $('#yz_modal').html('开始和结束时间不能跨月！')
            $('#yz_modal').addClass('active')
            tipShow()
            return
        }else if(end_time_edit_date <= start_time_edit_date){
            $('#yz_modal').html('结束日期不得小于或等于开始日期！')
            $('#yz_modal').addClass('active')
            tipShow()
            return
        }
        if(start_time_edit == '' || end_time_edit == '' || edit_equipmentName == '' || edit_name == '' || edit_department == '' || edit_workTime == ''){
            $('#yz_modal').html('您有内容没有填写完整！')
            $('#yz_modal').addClass('active')
            tipShow()
            return
        }

        $.ajax({
            url:'http://jk.com/Admin/ProDevice/editDevice',
            type:'post',
            data:{
                id:edit_id,
                dev_id: edit_equipmentName_id,
                staff_id: edit_name_id,
                start_time: start_time_edit,
                end_time: end_time_edit,
                work_hours: edit_workTime,
                work_record: edit_equipmentUseRecord
            },
            success:function(data){
                if(data.code==1){
                    let OldHTML = $('#table_table').find(`tr[data-index=${edit_id}]`)
                    let NewHTML = `
                            <td><input type="checkbox" class="checkboxStyle"></td>
                            <td data-name="start_time_edit">${start_time_edit}</td>
                            <td data-name="end_time_edit">${end_time_edit}</td>
                            <td data-name="edit_equipmentName">${edit_equipmentName}</td>
                            <td data-name="edit_equipmentNum">${edit_equipmentNum}</td>
                            <td data-name="edit_name">${edit_name}</td>
                            <td data-name="edit_department">${edit_department}</td>
                            <td data-name="edit_workTime">${edit_workTime}</td>
                            <td class="look_record" data-name="edit_workTimeRecord">
                                <a href="#" class="look_record_btn">查看记录</a>
                                <div class="tip_hiddenBox work_record_box">
                                    <span class="work_record_title">工时记录</span>
                                    <p class="work_record_main">${edit_equipmentUseRecord}</p>
                                    <button class="btn btn-sm btn-success">确认</button>
                                </div>
                            </td>
                            <td style><a href="edit_people" class="edit_table">编辑</a></td>
                    `
                    OldHTML.html(NewHTML)
                    $(that).parent().parent().removeClass('active')
                }else{

                }
            }
        })

    })

    // 确认按钮点击时
    $('#add_btn').click(function(){
        let start_time_add = $(this).closest('[lll]').find('[add_name=start_time_add]').val()
        let end_time_add = $(this).closest('[lll]').find('[add_name=end_time_add]').val()
        let add_equipment_id = $(this).closest('[lll]').find('[add_name=add_equipmentName] option:selected').val()
        let add_equipmentName = $(this).closest('[lll]').find('[add_name=add_equipmentName]').val()
        let add_equipmentNum = $(this).closest('[lll]').find('[add_name=add_equipmentNum]').val()
        let add_name = $(this).closest('[lll]').find('[add_name=add_name]').val()
        let add_department = $(this).closest('[lll]').find('[add_name=add_department]').val()
        let add_workTime = $(this).closest('[lll]').find('[add_name=add_workTime]').val()
        let add_equipmentUseRecord = $(this).closest('[lll]').find('[add_name=add_equipmentUseRecord]').val()/**/

        var start_timeList = start_time_add.split('-')
        var end_time_addList = end_time_add.split('-')
        var start_time_add_month = start_timeList[1]
        var end_time_add_month = end_time_addList[1]
        var start_time_add_date = start_timeList[2]
        var end_time_add_date = end_time_addList[2]

        if(start_time_add_month != end_time_add_month){
            $('#yz_modal').html('开始和结束时间不能跨月！')
            $('#yz_modal').addClass('active')
            tipShow()
            return
        }else if(end_time_add_date <= start_time_add_date){
            $('#yz_modal').html('结束日期不得小于或等于开始日期！')
            $('#yz_modal').addClass('active')
            tipShow()
            return
        }
        if(!add_equipmentUseRecord){
            add_equipmentUseRecord = '暂无'
        }
        if(start_time_add == '' || end_time_add == '' || add_equipmentName == '' || add_name == '' || add_department == '' || add_workTime == ''){
            $('#yz_modal').html('您有内容没有填写完整！')
            $('#yz_modal').addClass('active')
            tipShow()
            return
        }

        let that = this
        $.ajax({
            url:'http://jk.com/Admin/ProDevice/addDevice',
            type:'post',
            data:{
                dev_id: add_equipment_id,
                staff_id: add_name,
                start_time: start_time_add,
                end_time: end_time_add,
                work_hours: add_workTime,
                work_record: add_equipmentUseRecord
            },
            success:function(data){
                if(data.code==1){
                    var peopleTableHTML = $('#table_table').children('tbody').html()
                    peopleTableHTML += `
                    <tr data-index="${data.id}">
                            <td><input type="checkbox" class="checkboxStyle"></td>
                            <td data-name="start_time_edit">${start_time_add}</td>
                            <td data-name="end_time_edit">${end_time_add}</td>
                            <td data-name="edit_equipmentName">${add_equipmentName}</td>
                            <td data-name="edit_equipmentNum">${add_equipmentNum}</td>
                            <td data-name="edit_name">${add_name}</td>
                            <td data-name="edit_department">${add_department}</td>
                            <td data-name="edit_workTime">${add_workTime}</td>
                            <td class="look_record" data-name="edit_workTimeRecord">
                                <a href="#" class="look_record_btn">查看记录</a>
                                <div class="tip_hiddenBox work_record_box">
                                    <span class="work_record_title">工时记录</span>
                                    <p class="work_record_main">${add_equipmentUseRecord}</p>
                                    <button class="btn btn-sm btn-success">确认</button>
                                </div>
                            </td> 
                            <td style><a href="edit_people" class="edit_table">编辑</a></td>
                        </tr>
            `
                    $('#table_table').children('tbody').html(peopleTableHTML)

                    $(that).closest('[lll]').find('[add_name]').val('')
                    $(that).closest('[lll]').removeClass('active')
                }else{
                    $('#yz_modal').html(data.msg)
                    $('#yz_modal').addClass('active')
                    tipShow()
                }
            }
        })
    })
    // 确认并新增按钮点击时
    $('#add_AddNew_btn').click(function(){
        let start_time_add = $(this).closest('[lll]').find('[add_name=start_time_add]').val()
        let end_time_add = $(this).closest('[lll]').find('[add_name=end_time_add]').val()
        let add_equipment_id = $(this).closest('[lll]').find('[add_name=add_equipmentName] option:selected').val()
        let add_equipmentName = $(this).closest('[lll]').find('[add_name=add_equipmentName]').val()
        let add_equipmentNum = $(this).closest('[lll]').find('[add_name=add_equipmentNum]').val()
        let add_name = $(this).closest('[lll]').find('[add_name=add_name]').val()
        let add_department = $(this).closest('[lll]').find('[add_name=add_department]').val()
        let add_workTime = $(this).closest('[lll]').find('[add_name=add_workTime]').val()
        let add_equipmentUseRecord = $(this).closest('[lll]').find('[add_name=add_equipmentUseRecord]').val()/**/

        var start_timeList = start_time_add.split('-')
        var end_time_addList = end_time_add.split('-')
        var start_time_add_month = start_timeList[1]
        var end_time_add_month = end_time_addList[1]
        var start_time_add_date = start_timeList[2]
        var end_time_add_date = end_time_addList[2]

        if(start_time_add_month != end_time_add_month){
            $('#yz_modal').html('开始和结束时间不能跨月！')
            $('#yz_modal').addClass('active')
            tipShow()
            return
        }else if(end_time_add_date <= start_time_add_date){
            $('#yz_modal').html('结束日期不得小于或等于开始日期！')
            $('#yz_modal').addClass('active')
            tipShow()
            return
        }
        if(!add_equipmentUseRecord){
            add_equipmentUseRecord = '暂无'
        }
        if(start_time_add == '' || end_time_add == '' || add_equipmentName == '' || add_name == '' || add_department == '' || add_workTime == ''){
            $('#yz_modal').html('您有内容没有填写完整！')
            $('#yz_modal').addClass('active')
            tipShow()
            return
        }

        let that = this
        $.ajax({
            url:'http://jk.com/Admin/ProDevice/addDevice',
            type:'post',
            data:{
                dev_id: add_equipment_id,
                staff_id: add_name,
                start_time: start_time_add,
                end_time: end_time_add,
                work_hours: add_workTime,
                work_record: add_equipmentUseRecord
            },
            // xhrFields: {withCredentials: true},
            success:function(data){
                if(data.code==1){
                    var peopleTableHTML = $('#table_table').children('tbody').html()
                    peopleTableHTML += `
                    <tr data-index="${data.id}">
                            <td><input type="checkbox" class="checkboxStyle"></td>
                            <td data-name="start_time_edit">${start_time_add}</td>
                            <td data-name="end_time_edit">${end_time_add}</td>
                            <td data-name="edit_equipmentName">${add_equipmentName}</td>
                            <td data-name="edit_equipmentNum">${add_equipmentNum}</td>
                            <td data-name="edit_name">${add_name}</td>
                            <td data-name="edit_department">${add_department}</td>
                            <td data-name="edit_workTime">${add_workTime}</td>
                            <td class="look_record" data-name="edit_workTimeRecord">
                                <a href="#" class="look_record_btn">查看记录</a>
                                <div class="tip_hiddenBox work_record_box">
                                    <span class="work_record_title">工时记录</span>
                                    <p class="work_record_main">${add_equipmentUseRecord}</p>
                                    <button class="btn btn-sm btn-success">确认</button>
                                </div>
                            </td>
                            <td style><a href="edit_people" class="edit_table">编辑</a></td>
                        </tr>
            `
                    $('#table_table').children('tbody').html(peopleTableHTML)

                    $(that).closest('[lll]').find('[add_name]').val('')
                    // $(that).closest('[lll]').removeClass('active')
                }else{
                    $('#yz_modal').html(data.msg)
                    $('#yz_modal').addClass('active')
                    tipShow()
                }
            }
        })
    })

    // 取消按钮点击时
    $('.button_list').on('click','button',function(){
        if($(this).hasClass('cancel_btn')){
            $(this).closest('[lll]').removeClass('active')
        }
    })

    // 上传文件
    $('#file_upload').change(function (e) {
        $(this).siblings('.import_tip_btn_box').find('button').removeClass('btn-grey').addClass('btn-success')
    })
    $('#import').find('button').click(function(e){
        "use strict";
        e.preventDefault()
        if($(this).hasClass('btn-success')){
            if($(this).html()=='确定导入'){
                var formData = new FormData($("#file_form")[0]);
                $.ajax({
                    async : false,
                    cache : false,
                    type : "post",
                    data : formData,
                    url : 'http://jk.com/Admin/ProDevice/importDevice',
                    dataType : 'json',
                    contentType: false, //必须
                    processData: false, //必须
                    success : function(data) {
                        if(data.code==1){
                            $('#import').removeClass('active')
                        }else{
                            $('#yz_modal').html(data.msg)
                            $('#yz_modal').addClass('active')
                            tipShow()
                        }
                    }
                })
            }
        }

    })

    // 弹出来的小框框
    function tipShow(){
        window.tipBox = setTimeout(function(){
            // $('#yz_modal').removeClass('active')
            // $('#yz_modal').addClass('fadeOut')
            $('#yz_modal').removeClass('active')
            clearTimeout(tipBox)
        },2000)
    }
//关闭所有已选择的框框
    function checkBox(){
        var checkboxs =$('input[type=checkbox]');
        for (var i = 0; i < checkboxs.length; i++) {
            if (!checkboxs[i].checked) {
                continue;
            }else{
                $(checkboxs[i]).attr('checked',false)
            }
        }
    }

    //当点击区域不在导入弹框中时则关闭弹框
    $(document).click(function(e){
        let $this = $(e.target);
        if($this.closest('#import').length==0){
            if($this.attr('href') != '#import' && $this.children().attr('href') != '#import'){
                $('#import').removeClass('active');
            }
        }
    })

})